home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / BCTNL0 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  6.9 KB  |  216 lines

  1. package com.sun.java.swing.text;
  2.  
  3. import com.sun.java.swing.event.ChangeEvent;
  4. import com.sun.java.swing.event.ChangeListener;
  5. import com.sun.java.swing.event.EventListenerList;
  6. import java.io.IOException;
  7. import java.io.ObjectInputStream;
  8. import java.io.ObjectOutputStream;
  9. import java.io.Serializable;
  10. import java.util.Enumeration;
  11.  
  12. public class StyleContext$NamedStyle implements Style, Serializable {
  13.    // $FF: synthetic field
  14.    StyleContext this$0;
  15.    protected EventListenerList listenerList;
  16.    protected ChangeEvent changeEvent;
  17.    private transient AttributeSet attributes;
  18.  
  19.    // $FF: synthetic method
  20.    public StyleContext$NamedStyle(StyleContext this$0, String name, Style parent) {
  21.       this.this$0 = this$0;
  22.       this.listenerList = new EventListenerList();
  23.       this.changeEvent = null;
  24.       this.attributes = this$0.getEmptySet();
  25.       if (name != null) {
  26.          this.setName(name);
  27.       }
  28.  
  29.       if (parent != null) {
  30.          this.setResolveParent(parent);
  31.       }
  32.  
  33.    }
  34.  
  35.    // $FF: synthetic method
  36.    public StyleContext$NamedStyle(StyleContext this$0, Style parent) {
  37.       this(this$0, (String)null, parent);
  38.       this.this$0 = this$0;
  39.    }
  40.  
  41.    // $FF: synthetic method
  42.    public StyleContext$NamedStyle(StyleContext this$0) {
  43.       this.this$0 = this$0;
  44.       this.listenerList = new EventListenerList();
  45.       this.changeEvent = null;
  46.       this.attributes = this$0.getEmptySet();
  47.    }
  48.  
  49.    public String toString() {
  50.       return "NamedStyle:" + this.getName() + " " + this.attributes;
  51.    }
  52.  
  53.    public String getName() {
  54.       return this.isDefined(StyleConstants.NameAttribute) ? (String)this.getAttribute(StyleConstants.NameAttribute) : null;
  55.    }
  56.  
  57.    public void setName(String name) {
  58.       if (name != null) {
  59.          this.addAttribute(StyleConstants.NameAttribute, name);
  60.       }
  61.  
  62.    }
  63.  
  64.    public void addChangeListener(ChangeListener l) {
  65.       EventListenerList var10000 = this.listenerList;
  66.       Class var10001 = StyleContext.class$com$sun$java$swing$event$ChangeListener;
  67.       if (var10001 == null) {
  68.          try {
  69.             var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
  70.          } catch (ClassNotFoundException var2) {
  71.             throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  72.          }
  73.  
  74.          StyleContext.class$com$sun$java$swing$event$ChangeListener = var10001;
  75.       }
  76.  
  77.       var10000.add(var10001, l);
  78.    }
  79.  
  80.    public void removeChangeListener(ChangeListener l) {
  81.       EventListenerList var10000 = this.listenerList;
  82.       Class var10001 = StyleContext.class$com$sun$java$swing$event$ChangeListener;
  83.       if (var10001 == null) {
  84.          try {
  85.             var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
  86.          } catch (ClassNotFoundException var2) {
  87.             throw new NoClassDefFoundError(((Throwable)var2).getMessage());
  88.          }
  89.  
  90.          StyleContext.class$com$sun$java$swing$event$ChangeListener = var10001;
  91.       }
  92.  
  93.       var10000.remove(var10001, l);
  94.    }
  95.  
  96.    protected void fireStateChanged() {
  97.       Object[] listeners = this.listenerList.getListenerList();
  98.  
  99.       for(int i = listeners.length - 2; i >= 0; i -= 2) {
  100.          Object var10000 = listeners[i];
  101.          Class var10001 = StyleContext.class$com$sun$java$swing$event$ChangeListener;
  102.          if (var10001 == null) {
  103.             try {
  104.                var10001 = Class.forName("com.sun.java.swing.event.ChangeListener");
  105.             } catch (ClassNotFoundException var3) {
  106.                throw new NoClassDefFoundError(((Throwable)var3).getMessage());
  107.             }
  108.  
  109.             StyleContext.class$com$sun$java$swing$event$ChangeListener = var10001;
  110.          }
  111.  
  112.          if (var10000 == var10001) {
  113.             if (this.changeEvent == null) {
  114.                this.changeEvent = new ChangeEvent(this);
  115.             }
  116.  
  117.             ((ChangeListener)listeners[i + 1]).stateChanged(this.changeEvent);
  118.          }
  119.       }
  120.  
  121.    }
  122.  
  123.    public int getAttributeCount() {
  124.       return this.attributes.getAttributeCount();
  125.    }
  126.  
  127.    public boolean isDefined(Object attrName) {
  128.       return this.attributes.isDefined(attrName);
  129.    }
  130.  
  131.    public boolean isEqual(AttributeSet attr) {
  132.       return this.attributes.isEqual(attr);
  133.    }
  134.  
  135.    public AttributeSet copyAttributes() {
  136.       StyleContext$NamedStyle a = new StyleContext$NamedStyle(this.this$0);
  137.       a.attributes = this.attributes.copyAttributes();
  138.       return a;
  139.    }
  140.  
  141.    public Object getAttribute(Object attrName) {
  142.       return this.attributes.getAttribute(attrName);
  143.    }
  144.  
  145.    public Enumeration getAttributeNames() {
  146.       return this.attributes.getAttributeNames();
  147.    }
  148.  
  149.    public boolean containsAttribute(Object name, Object value) {
  150.       return this.attributes.containsAttribute(name, value);
  151.    }
  152.  
  153.    public boolean containsAttributes(AttributeSet attrs) {
  154.       return this.attributes.containsAttributes(attrs);
  155.    }
  156.  
  157.    public AttributeSet getResolveParent() {
  158.       return this.attributes.getResolveParent();
  159.    }
  160.  
  161.    public void addAttribute(Object name, Object value) {
  162.       StyleContext context = this.this$0;
  163.       this.attributes = context.addAttribute(this.attributes, name, value);
  164.       this.fireStateChanged();
  165.    }
  166.  
  167.    public void addAttributes(AttributeSet attr) {
  168.       StyleContext context = this.this$0;
  169.       this.attributes = context.addAttributes(this.attributes, attr);
  170.       this.fireStateChanged();
  171.    }
  172.  
  173.    public void removeAttribute(Object name) {
  174.       StyleContext context = this.this$0;
  175.       this.attributes = context.removeAttribute(this.attributes, name);
  176.       this.fireStateChanged();
  177.    }
  178.  
  179.    public void removeAttributes(Enumeration names) {
  180.       StyleContext context = this.this$0;
  181.       this.attributes = context.removeAttributes(this.attributes, names);
  182.       this.fireStateChanged();
  183.    }
  184.  
  185.    public void removeAttributes(AttributeSet attrs) {
  186.       StyleContext context = this.this$0;
  187.       if (attrs == this) {
  188.          this.attributes = context.getEmptySet();
  189.       } else {
  190.          this.attributes = context.removeAttributes(this.attributes, attrs);
  191.       }
  192.  
  193.       this.fireStateChanged();
  194.    }
  195.  
  196.    public void setResolveParent(AttributeSet parent) {
  197.       if (parent != null) {
  198.          this.addAttribute(StyleConstants.ResolveAttribute, parent);
  199.       } else {
  200.          this.removeAttribute(StyleConstants.ResolveAttribute);
  201.       }
  202.  
  203.    }
  204.  
  205.    private void writeObject(ObjectOutputStream s) throws IOException {
  206.       s.defaultWriteObject();
  207.       StyleContext.writeAttributeSet(s, this.attributes);
  208.    }
  209.  
  210.    private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
  211.       s.defaultReadObject();
  212.       this.attributes = SimpleAttributeSet.EMPTY;
  213.       StyleContext.readAttributeSet(s, this);
  214.    }
  215. }
  216.